<template>
  <z-paging ref="paging" v-model="dataList" @query="queryList">
    <!-- z-paging默认铺满全屏，此时页面所有view都应放在z-paging标签内，否则会被盖住 -->
    <!-- 需要固定在页面顶部的view请通过slot="top"插入，包括自定义的导航栏 -->
    <!-- 猜你喜欢 -->
    <template #top>
      <view>
        <u-search
          :show-action="true"
          actionText="搜索"
          v-model="searchParam.name"
          :animation="true"
        ></u-search>
        <u-button type="primary" @click="searchData">搜索</u-button>
        <up-tabs :list="list1" @click="changeTab"></up-tabs>
      </view>
    </template>
    <view class="caption">
      <text class="text">猜你喜欢</text>
    </view>
    <view class="guess">
      <navigator
        class="guess-item"
        v-for="item in dataList"
        :key="item.id"
        :url="`/pages/goods/goods?id=4007498`"
      >
        <image class="image" mode="aspectFill" :src="item.picture"></image>
        <view class="name">{{ item.desc }}</view>
        <view class="price">
          <text class="small">¥</text>
          <text>{{ item.price }}</text>
        </view>
      </navigator>
    </view>
  </z-paging>
</template>

<script setup>
import { getGuessYouLikeApi } from "@/api/index";

const { dataList, paging, queryList, searchData, searchParam } = usePaging({
  listApi: getGuessYouLikeApi,
  otherParam: { id: "1001", type: 2 },
});
const list1 = reactive([
  { name: "全部", value: "" },
  { name: "待付款", value: 1 },
  { name: "已付款", value: 2 },
  { name: "代发货", value: 7 },
]);
const changeTab = (item) => {
  console.log("item: ", item);
  searchParam.value.state = item.value;
  searchData();
};
</script>

<style lang="scss" scoped>
:host {
  display: block;
}
/* 分类标题 */
.caption {
  display: flex;
  justify-content: center;
  line-height: 1;
  padding: 36rpx 0 40rpx;
  font-size: 32rpx;
  color: #262626;
  .text {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 28rpx 0 30rpx;

    &::before,
    &::after {
      content: "";
      width: 20rpx;
      height: 20rpx;
      // background-image: url(@/static/images/bubble.png);
      // background-size: contain;
      margin: 0 10rpx;
    }
  }
}

/* 猜你喜欢 */
.guess {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 0 20rpx;
  .guess-item {
    width: 305rpx;
    padding: 24rpx 20rpx 20rpx;
    margin-bottom: 20rpx;
    border-radius: 10rpx;
    overflow: hidden;
    background-color: #fff;
  }
  .image {
    width: 304rpx;
    height: 304rpx;
  }
  .name {
    height: 75rpx;
    margin: 10rpx 0;
    font-size: 26rpx;
    color: #262626;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .price {
    line-height: 1;
    padding-top: 4rpx;
    color: #cf4444;
    font-size: 26rpx;
  }
  .small {
    font-size: 80%;
  }
}
</style>
